﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="BackupViewModelTests.cs" company="Concept Architecture">
//   (c) 2010 Muhammad Umer Farooq
// </copyright>
// <summary>
//   Defines the <seealso cref="Hisaab.Client.Test.ViewModel.BackupViewModelTests" /> type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Hisaab.Client.Test.ViewModel
{
    using System;
    using System.IO;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Windows.Client.ViewModel;

    /// <summary>
    /// Defines the <seealso cref="Hisaab.Client.Test.ViewModel.BackupViewModelTests"/> type.
    /// </summary>
    [TestClass]
    public class BackupViewModelTests
    {
        /// <summary>
        /// Propertieses the should raise notify property changed.
        /// </summary>
        [TestMethod]
        public void PropertiesShouldRaiseNotifyPropertyChanged()
        {
            var viewModel = new BackupViewModel();

            var tester = new NotifyPropertyChangedTester(viewModel);

            Assert.AreEqual(0, tester.Changes.Count, "Changes count was wrong.");

            viewModel.BackupPath = @"c:\backup\";

            Assert.AreEqual(1, tester.Changes.Count, "Changes count was wrong.");

            tester.AssertChange(0, "BackupPath");
        }

        /// <summary>
        /// Queries the command should return A delegate.
        /// </summary>
        [TestMethod]
        public void QueryCommandShouldReturnADelegate()
        {
            var viewModel = new BackupViewModel();
            var command = viewModel.BackupCommand;
            Assert.IsNotNull(command);
        }

        /// <summary>
        /// Determines whether this instance [can execute backup should return false if back up path is null].
        /// </summary>
        [TestMethod]
        public void CanExecuteBackupShouldReturnFalseIfBackUpPathIsNull()
        {
            var viewModel = new BackupViewModel { BackupPath = null };
            Assert.IsFalse(viewModel.CanExecuteBackup());
        }

        /// <summary>
        /// Determines whether this instance [can execute backup should return false if back up path is empty].
        /// </summary>
        [TestMethod]
        public void CanExecuteBackupShouldReturnFalseIfBackUpPathIsEmpty()
        {
            var viewModel = new BackupViewModel { BackupPath = String.Empty };
            Assert.IsFalse(viewModel.CanExecuteBackup());
        }

        /// <summary>
        /// Determines whether this instance [can execute backup should return false if back up path does not exists].
        /// </summary>
        [TestMethod]
        public void CanExecuteBackupShouldReturnFalseIfBackUpPathDoesNotExists()
        {
            var viewModel = new BackupViewModel { BackupPath = @"X:\Some\Path\That\Does\Not\exist" };
            Assert.IsFalse(viewModel.CanExecuteBackup());
        }

        /// <summary>
        /// Determines whether this instance [can execute backup should return true if back up path is valid].
        /// </summary>
        [TestMethod]
        public void CanExecuteBackupShouldReturnTrueIfBackUpPathIsValid()
        {
            var viewModel = new BackupViewModel { BackupPath = Path.GetTempFileName() };
            Assert.IsTrue(viewModel.CanExecuteBackup());
        }
    }
}